<?php require_once("header.php");?>
	<div id="content">
		<div id="content-title">
			Search Result
		</div>
           <div id="isi-content">
<?php
	require_once("db.php");
	if(connect_db()){
		$q_username = $_GET['query_username'];
		$q_title = $_GET['query_title'];
		$q_tag = $_GET['query_tag'];
		// To protect MySQL injection
		$q_username = stripslashes($q_username);
		$q_title = stripslashes($q_title);
		$q_tag = stripslashes($q_tag);
		$q_username = mysql_real_escape_string($q_username);
		$q_title = mysql_real_escape_string($q_title);
		$q_tag = mysql_real_escape_string($q_tag);

		$tbl_name="content"; // Table name

		$sql="SELECT * FROM konten WHERE username ='$q_username' OR judul='$q_title' OR id_konten IN (SELECT id_konten FROM tag WHERE Tag LIKE '$q_tag')";
		$result=mysql_query($sql);
		while ($row = mysql_fetch_array($result)) {
			?>
            <h3><a href="content.php?id=<?php echo $row['id_konten'];?>" style="text-decoration:none;"><?php echo $row['judul'];?></a></h3>
			<img border="0" src="<?php echo $row['url'];?>" alt="<?php echo $row['judul'];?>" width="304" height="228" />
            <br/> 
        <?php          
		}
		?>
          </div>
	</div>
<?php
	}
	require_once("footer.php");
?>
